﻿//-----------------------------------------------
// <copyright file="WorkerWindow.xaml.cs" company="FER">
//     Copyright (c) All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace NMBP_odb
{
    using System.Windows;
    using GalaSoft.MvvmLight.Messaging;
    using NMBP.Models;
    using NMBP.View.ViewModel;

    /// <summary>
    /// Interaction logic for WorkerWindow.xaml
    /// </summary>
    public partial class WorkerWindow : Window
    {
        /// <summary>
        /// Initializes a new instance of the WorkerWindow class
        /// </summary>
        public WorkerWindow()
        {
            InitializeComponent();

            Messenger.Default.Register<Worker>(
                this,
                "OpenAdminWindow",
                (msg) =>
                    {
                        AdminWindow adminWindow = new AdminWindow();
                        Messenger.Default.Send<Worker>(msg, "InitializeAdmin");
                        adminWindow.Show();
                        this.Close();
                    });

            this.Closing += ((s, e) =>
                                 {
                                     ViewModelLocator.ClearWorkerViewModel();
                                     Messenger.Default.Unregister(this);
                                 });
        }
    }
}
